@echo off
echo Testing Announcement APIs...

REM 设置基础URL和认证token（需要先登录获取）
set BASE_URL=http://localhost:8080/api/announcements
set AUTH_TOKEN=your_jwt_token_here

echo.
echo 1. 测试获取公开公告列表（无需认证）
curl -X GET "%BASE_URL%/public"

echo.
echo 2. 测试创建新公告（需要ADMIN或MODERATOR权限）
curl -X POST "%BASE_URL%" ^
  -H "Authorization: Bearer %AUTH_TOKEN%" ^
  -H "Content-Type: application/json" ^
  -d "{\"title\":\"Test Announcement\",\"content\":\"This is a test announcement\",\"isPublished\":false}"

echo.
echo 3. 获取所有公告（包括未发布的，需要ADMIN或MODERATOR权限）
curl -X GET "%BASE_URL%" ^
  -H "Authorization: Bearer %AUTH_TOKEN%"

echo.
echo 4. 根据ID获取公告详情
curl -X GET "%BASE_URL%/1"

echo.
echo 5. 更新公告（需要ADMIN或MODERATOR权限）
curl -X PUT "%BASE_URL%/1" ^
  -H "Authorization: Bearer %AUTH_TOKEN%" ^
  -H "Content-Type: application/json" ^
  -d "{\"title\":\"Updated Announcement\",\"content\":\"This announcement has been updated\",\"isPublished\":false}"

echo.
echo 6. 发布公告（需要ADMIN或MODERATOR权限）
curl -X PUT "%BASE_URL%/1/publish" ^
  -H "Authorization: Bearer %AUTH_TOKEN%" ^
  -d "isPublished=true"

echo.
echo 7. 删除公告（需要ADMIN或MODERATOR权限）
curl -X DELETE "%BASE_URL%/1" ^
  -H "Authorization: Bearer %AUTH_TOKEN%"

echo.
echo Testing completed!